package ar.edu.caece.compiler.grammar;

import static org.apache.commons.logging.LogFactory.getLog;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;

import ar.edu.caece.compiler.grammar.attributes.Attribute;
import ar.edu.caece.compiler.grammar.attributes.AttributeAware;


public class NonTerminalSymbol implements AttributeAware{
	
	private Log logger = getLog(NonTerminalSymbol.class);	
	private Map<String,Attribute> attributes;
	
	public NonTerminalSymbol() {
		this.attributes = new HashMap<String,Attribute>();
		StringBuilder logLine = new StringBuilder();
		
		logLine.append("Instanciando nuevo no terminal: " + this.getClass().getSimpleName() + " -> ");
		
		for(Class<?> parameterTypes : this.getClass().getConstructors()[0].getParameterTypes()) {
				logLine.append(parameterTypes.getSimpleName() + " ");
		}
		
		logger.debug(logLine);
	}

	@Override
	public void addAttribute(String name, Attribute attribute) {
		this.attributes.put(name, attribute);
		
	}

	@Override
	public void clearAttributes() {
		this.attributes.clear();
	}

	@Override
	public Attribute getAttribute(String name) {
		return this.attributes.get(name);
	}

	@Override
	public Map<String, Attribute> getAttributes() {
		return this.attributes;
	}

	@Override
	public void setAttributes(Map<String, Attribute> attributes) {
		this.attributes = attributes;
		
	}
}
